import numpy as np
import h5py

# HDF5文件的路径
hdf5_path = '2017_2019_images_pv_processed.hdf5'

# 打开HDF5文件
with h5py.File(hdf5_path, 'r') as f:
    # 读取测试集的数据
    image_log_test = f['/test/images_log'][:]
    pv_log_test = f['/test/pv_log'][:]
    
    # 读取训练验证集的数据
    image_log_trainval = f['/trainval/images_log'][:]
    pv_log_trainval = f['/trainval/pv_log'][:]
    
    # # 将数据保存为.npy文件
    np.save('./deconstruction_data/image_log_test.npy', image_log_test)
    np.save('./deconstruction_data/pv_log_test.npy', pv_log_test)
    np.save('./deconstruction_data/image_log_trainval.npy', image_log_trainval)
    np.save('./deconstruction_data/pv_log_trainval.npy', pv_log_trainval)

print("Data has been successfully saved as .npy files.")